/// 
/// Author: Jeff Liu
/// Date: 2023-04-18 00:22:00
/// LastEditTime: 2023-04-25 23:06:07
/// LastEditors: Jeff Liu
/// Description: 
/// FilePath: /HCC3T/src/HCC/SVR/PubSub/Topic.cls
/// Jeff.liu@intersytems.com
/// 
/// 可订阅的主题类
Class HCC.SVR.PubSub.Topic Extends (%Persistent, %XML.Adaptor, %JSON.Adaptor)
{

/// 主题名称
Property TopicName As %String;

/// 主题类型 schema 名字
Property SchemaType As %String;

/// 主题描述    
Property Description As %String;

/// 创建时间
Property CreatedAt As %TimeStamp [ InitialExpression = {$ZDATETIME($ZDATETIMEH($ZTS,-3),3,1,4)} ];

/// 主题名称不能重复
Index IdxTopicName On TopicName [ Unique ];

/// 触发器删除主题时删除所有订阅
Trigger CleanSubscriptionT [ Event = DELETE, Foreach = row/object, Time = AFTER ]
{
   
    New id,SQLCODE
    Set id = {ID}
    &SQL(DELETE FROM HCC_SVR_PubSub.Subscription WHERE Topic = :id)
    If SQLCODE<0 
    {
    Set baderr="SQLCODE ERROR:"_SQLCODE_" "_%msg
    Set %ok=0         
    Return baderr 
    }
}


}
